#!/bin/bash


install_git(){
	if which opkg;then
		echo '[info] opkg'
		# opkg update
		# opkg install git
		opkg update
		# opkg remove git
		opkg install git-http
		opkg install ca-bundle
	elif which apt;then
		echo '[info] apt maybe need root'
		sudo apt update
		sudo apt install git
	fi
}

if ! which git;then

	echo '[I] install git'
	install_git
	if ! which git;then
		echo "[E] install git failed"
	fi
	echo ""
	echo "###########"
	echo ""
fi






(
cd "$(dirname "$0")"
pwd


#dst="/home/hbl/services/fileserver/file_server_data/box1_more_and_more"
dst="/home/hbl/services/f2/data/v3_tvbox_server/more_and_more"

if [ ! -d "$dst" ];then
        echo '[err] $dst must be dir'
        exit
fi

for i in */install.sh;do
	echo "[i] install $i"
	bash "$i" "$dst"
	echo ""
	echo "###########"
	echo ""
done

)

(
	curl "http://v3.tv.server.lan:19999/api/proxy_clear_cache"
	curl "http://x.tv.server.lan:19999/api/proxy_clear_cache"
)

